package com.ss.whisper2.rabbitmq.topic;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class TopicRabbitConfig {
	//绑定键

	public final static String COURSE_SELECT = "topic.course.select";

	@Bean
	public Queue thirdQueue() {
		return new Queue(TopicRabbitConfig.COURSE_SELECT);
	}

	@Bean
	TopicExchange exchange() {
		return new TopicExchange("topicExchange");
	}


	//将secondQueue和topicExchange绑定,而且绑定的键值为用上通配路由键规则topic.#
	// 这样只要是消息携带的路由键是以topic.开头,都会分发到该队列

	@Bean
	Binding bindingExchangeMessage3() {
		return BindingBuilder.bind(thirdQueue()).to(exchange()).with(COURSE_SELECT);
	}

}
